#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>

//子进程先退出，父进程一直不回收，子进程就一直处于僵尸状态
int main()
{
    pid_t id = fork();
    if(id < 0) return 1;
    else if(id == 0)
    {
        //子进程
        int cnt = 5;
        while(cnt)
        {
            printf("I am child, run times: %d\n", cnt--);
            sleep(1);
        }
        printf("I am child, dead!");
        //exit(2);
    }
    else
    {
        //父进程
        while(1)
        {
            printf("I am father, running any time!\n");
            sleep(1);
        }
    }
    return 0;
}
